<template>
	<!-- 登录界面 -->
	<view class="top">
		<image style="width: 100%;height: 300rpx;" src="../../../static/image/starSky.jpg"></image>
	</view>
	<view class="mid">
		<uni-section title="账号" type="line" padding>
			<uni-easyinput v-model="loginData.username" placeholder="请输入账号"></uni-easyinput>
		</uni-section>

		<uni-section title="密码" type="line" padding>
			<uni-easyinput v-model="loginData.password" type="password" placeholder="请输入密码"></uni-easyinput>
		</uni-section>

		<button type="primary" @click="login">登录</button>
	</view>
</template>

<script>
	import config from '../../../utils/config.js'
	export default {
		data() {
			return {
				loginData: {
					username: '',
					password: '',
				}
			}
		},
		methods: {
			login() {
				let that = this
				this.request({
					url: config.baseUrl + "/wx/loginWx",
					data: {
						username: that.loginData.username,
						password: that.loginData.password,
					},
				}).then(res => {
					if (res.status === 200) {
						uni.setStorageSync('userData', res.data);
						console.log(uni.getStorageSync('userData'))
						uni.reLaunch({
							url: '/pages/mine/index'
						})
					} else {
						alert(res.text)
					}
				})
			}
		},
	}
</script>

<style>
	page {
		background-color: #eee;
	}

	.top {
		height: 300rpx;


	}
</style>